{template 'common/header'}
{template 'common'}
<ul class="nav nav-tabs">
    <li {if $operation=='display'} class="active" {/if}>
    <a href="{php echo $this->createWebUrl('currency',array('op' =>'display'))}">汇率列表</a>
    </li>
    <li {if empty($currency['id']) && $operation == 'post'} class="active" {/if}>
    <a href="{php echo $this->createWebUrl('currency',array('op' =>'post'))}">添加汇率</a>
    </li>
    {if !empty($currency['id']) && $operation == 'post'}
    <li class="active">
        <a href="{php echo $this->createWebUrl('currency',array('op' =>'post','id'=>$currency['id']))}">编辑汇率</a>
    </li>
    {/if}
</ul>

<!--列表-->
{if $operation == 'display'}
<div class="main panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:30px;">ID</th>
                <th>货币名称</th>
                <th>货币缩写</th>
                <th>符号</th>
                <th>汇率</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $currency}
            <tr>
                <td>{$currency['id']}</td>
                <td>{$currency['name']}</td>
                <td>{$currency['short_name']}</td>
                <td>{$currency['symbol']}</td>
                <td>{$currency['exchange_rate']}</td>
                <td style="text-align:left;">
                    <a href="{php echo $this->createWebUrl('currency', array('op' => 'post', 'id' => $currency['id']))}"
                       class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改">
                        <i class="fa fa-edit"></i>
                    </a>
                    <a href="{php echo $this->createWebUrl('currency', array('op' => 'delete', 'id' => $currency['id']))}"
                       class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除">
                        <i class="fa fa-times"></i>
                    </a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        {$pager}
    </div>`
</div>
<script>
    require(['bootstrap'], function ($) {
        $('.btn').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
    });
</script>

<!--增加修改-->
{elseif $operation == 'post'}
<div class="main">
    <form id="form1" action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$currency['id']}"/>
        <div class="panel panel-default">
            <div class="panel-heading">
                货币设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="name">
                        <span style="color:red">*</span>
                        货币名称
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='name' name="name" class="form-control" value="{$currency['name']}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="short_name">
                        <span style="color:red">*</span>
                        货币缩写
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='short_name' name="short_name" class="form-control" value="{$currency['short_name']}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="symbol">
                        <span style="color:red">*</span>
                        符号
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='symbol' name="symbol" class="form-control" value="{$currency['symbol']}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="symbol">
                        <span style="color:red">*</span>
                        汇率
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='exchange_rate' name="exchange_rate" class="form-control" value="{$currency['exchange_rate']}"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"/>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </form>
</div>

<script language='javascript'>
    $(function () {
        $("#form1").submit(function () {
            if ($(":text[name='name']").val() == '') {
                Tip.focus("name", "请填写货币名称!");
                return false;
            }
            if ($(":text[name='short_name']").val() == '') {
                Tip.focus("short_name", "请填写货币缩写!");
                return false;
            }
            if ($(":text[name='symbol']").val() == '') {
                Tip.focus("symbol", "请填写符号!");
                return false;
            }
            if ($(":text[name='exchange_rate']").val() == '') {
                Tip.focus("exchange_rate", "请填写汇率!");
                return false;
            }
            return true;
        });
    });
</script>
{/if}
{template 'common/footer'}